#----------------------------
# Name: Chris Spooner
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 9/17/2013
# Version: 1.0.0
#----------------------------

swearFilter = ["dumb",
               "stupid",
               "retard",
               "bitch",
               "nigger",
               "nigga",
               "cunt",
               "ass",
              "shity",
               "shit",
              "fuck",
               "fucking shit",
               "fricen",
               "bob",
               "ass fuck",
               "anus",
               "vajina",
               "vajayajay",
              " pussy",
              "dick",
              "rap",
              "slut",
              "whore",
              "dick",
              "joe",
              "peinis",
              "dong"]
 
def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")
    
           
def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+1):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if not goodOption:
            print "Please pick a valid option!"
    return option
        
def menu(options):
    print "------Please Select a Story------"
    print " [1] The End of the Day"
    print " [2] My New Pet"
    print " [Q] Quit"
    print "----------------------------------"
    option = getMenuOption(options)
    return option
    
def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "how dare you say that word you will never get laid in you life."
        if not goodWord:
            print "try later"
    return word
    
def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num
        
def story1():
    place1 = getWord("Enter a place: ")
    adjetive1 = getWord("enter an adjetive: ")
    noun1 = getWord("enter a noun: ")
    name1 = getWord("enter a name: ")
    verb1 = getWord("enter a verb: ")
    std = getWord("enter std: ")
    story = "It was a cloudy night in a place called"
    story += " " + place1 + ", "
    story += "It was"
    story += " " + adjetive1 + ". "
    story += "there was a boy named"
    story += " " + name1 + ". "
    story += "A man jumped out at you so you started"
    story += " " + verb1 + " away. "
    story += "he was geting closer so you decided to"
    story += " " + noun1 + " "
    story += "you finaly got away from him but then you got"
    story += " " + std + ". "
    print story
    print
    
def story2():
    name = getWord("Enter a name: ")
    age = getNumber("Enter a number: ")
    verb = getWord ("enter a verb: ")
    story = "I got a new pet and I named it"
    story += " " + name + ". "
    story += "I think " + name + " died."
    story += "I was very sad so I"
    story += " " + verb + " off a cliff." 
    print story
    print
    
def run():
    displayStartScreen()
    choice = ""
    while choice != 'Q':
        choice = menu(2)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == 'Q':
            displayEndScreen()
        else:
            print "Something Awful Ocurred...yell at programmer!"
    exit()
run()